const mongoose = require('mongoose')

mongoose.connect('mongodb://127.0.0.1:27017/data');

mongoose.connection.on('open',()=>{
    //创建数据骨架
    let userSchema = new mongoose.Schema({
        name:{
            type:String,
            default:'yuonly',
            unique:true
        },
        age:{
            type:String,
            default:20
        }
    })

    let userModel = mongoose.model('user',userSchema);
    // userModel.updateOne({name:'huhan'},{age:19},(err,data)=>{
    //     console.log(data);
    // })
    userModel.updateMany({age:19},{age:20},(err,data)=>{
        console.log(data);
    })
})